<?php 

/**
 * Gallery Edit Photo
 *
 * @package Bd Gallery
 * @author Bebliuc George Cristian
 * @author Gianfranco Liporace
 * @copyright 2008-2010
 * @version 1.3
 * @access public
 * @permisions Modify, Redistribute but leave the credits alive :P
 * @use Noncommercial, for commercial use, please contact me at bebliuc.george@gmail.com, it's for free, but I need to know
 *
 */

$photo = Photos::findById($id);
$categories = Category::findAllFrom('Category');

$photo_category_list = "";

foreach($categories as $category) {
    if($category->getId() == $photo->getCategory()) {
        $selected = "selected='';";
    } else {
        $selected = "";
    }
    $photo_category_list .= "<option value=\"{$category->getId()}\" {$selected}>{$category->getName()}</option>";
}
?>
<h1><?php echo __('Edit Photo'); ?></h1>
<form method="POST" action="<?php echo get_url('plugin/gallery/_edit_photo'); ?>">
    <div class="form-area">
        <p class="title">
            <label for="phototitle"><?php echo __('Photo title'); ?></label>
            <input type="text" name="phototitle" class="textbox" value="<?php echo $photo->getTitle(); ?>" /><br />
            <label for="photodescription"><?php echo __('Photo Description'); ?></label>
            <textarea name="photodescription" class="textarea"><?php echo $photo->getCaption(); ?></textarea><br />
            <label for="phototitle"><?php echo __('Photo Category'); ?></label>
            <select name="category"><?php echo $photo_category_list; ?></select>
            <input type="hidden" name="photoid" value="<?php echo $id; ?>" />
        </p>
    </div>
    <p class="buttons">
        <input class="button" type="submit" value="<?php echo __('Save'); ?>" />
        <input class="button" type="reset" value="<?php echo __('Reset'); ?>" />
        <input class="button" type="button" onclick='window.location.href = "<?php echo get_url('plugin/gallery/index'); ?>";' value="<?php echo __('Cancel'); ?>" />
    </p>
</form>
